<!DOCTYPE html><html><head>
<title>doctools::toc::structure - Documentation tools</title>
<style type="text/css"><!--
    HTML {
	background: 	#FFFFFF;
	color: 		black;
    }
    BODY {
	background: 	#FFFFFF;
	color:	 	black;
    }
    DIV.doctools {
	margin-left:	10%;
	margin-right:	10%;
    }
    DIV.doctools H1,DIV.doctools H2 {
	margin-left:	-5%;
    }
    H1, H2, H3, H4 {
	margin-top: 	1em;
	font-family:	sans-serif;
	font-size:	large;
	color:		#005A9C;
	background: 	transparent;
	text-align:		left;
    }
    H1.doctools_title {
	text-align: center;
    }
    UL,OL {
	margin-right: 0em;
	margin-top: 3pt;
	margin-bottom: 3pt;
    }
    UL LI {
	list-style: disc;
    }
    OL LI {
	list-style: decimal;
    }
    DT {
	padding-top: 	1ex;
    }
    UL.doctools_toc,UL.doctools_toc UL, UL.doctools_toc UL UL {
	font:		normal 12pt/14pt sans-serif;
	list-style:	none;
    }
    LI.doctools_section, LI.doctools_subsection {
	list-style: 	none;
	margin-left: 	0em;
	text-indent:	0em;
	padding: 	0em;
    }
    PRE {
	display: 	block;
	font-family:	monospace;
	white-space:	pre;
	margin:		0%;
	padding-top:	0.5ex;
	padding-bottom:	0.5ex;
	padding-left:	1ex;
	padding-right:	1ex;
	width:		100%;
    }
    PRE.doctools_example {
	color: 		black;
	background: 	#f5dcb3;
	border:		1px solid black;
    }
    UL.doctools_requirements LI, UL.doctools_syntax LI {
	list-style: 	none;
	margin-left: 	0em;
	text-indent:	0em;
	padding:	0em;
    }
    DIV.doctools_synopsis {
	color: 		black;
	background: 	#80ffff;
	border:		1px solid black;
	font-family:	serif;
	margin-top: 	1em;
	margin-bottom: 	1em;
    }
    UL.doctools_syntax {
	margin-top: 	1em;
	border-top:	1px solid black;
    }
    UL.doctools_requirements {
	margin-bottom: 	1em;
	border-bottom:	1px solid black;
    }
--></style>
</head>
<!-- Generated from file 'toc_structure.man' by tcllib/doctools with format 'html'
   -->
<!-- Copyright &amp;copy; 2009 Andreas Kupries &amp;lt;andreas_kupries@users.sourceforge.net&amp;gt;
   -->
<!-- doctools::toc::structure.n
   -->
<body><hr> [
   <a href="../../../../../../../../home">Tcllib Home</a>
&#124; <a href="../../../../toc.html">Main Table Of Contents</a>
&#124; <a href="../../../toc.html">Table Of Contents</a>
&#124; <a href="../../../../index.html">Keyword Index</a>
&#124; <a href="../../../../toc0.html">Categories</a>
&#124; <a href="../../../../toc1.html">Modules</a>
&#124; <a href="../../../../toc2.html">Applications</a>
 ] <hr>
<div class="doctools">
<h1 class="doctools_title">doctools::toc::structure(n) 0.1 tcllib &quot;Documentation tools&quot;</h1>
<div id="name" class="doctools_section"><h2><a name="name">Name</a></h2>
<p>doctools::toc::structure - Doctoc serialization utilities</p>
</div>
<div id="toc" class="doctools_section"><h2><a name="toc">Table Of Contents</a></h2>
<ul class="doctools_toc">
<li class="doctools_section"><a href="#toc">Table Of Contents</a></li>
<li class="doctools_section"><a href="#synopsis">Synopsis</a></li>
<li class="doctools_section"><a href="#section1">Description</a></li>
<li class="doctools_section"><a href="#section2">API</a></li>
<li class="doctools_section"><a href="#section3">ToC serialization format</a></li>
<li class="doctools_section"><a href="#section4">Bugs, Ideas, Feedback</a></li>
<li class="doctools_section"><a href="#keywords">Keywords</a></li>
<li class="doctools_section"><a href="#category">Category</a></li>
<li class="doctools_section"><a href="#copyright">Copyright</a></li>
</ul>
</div>
<div id="synopsis" class="doctools_section"><h2><a name="synopsis">Synopsis</a></h2>
<div class="doctools_synopsis">
<ul class="doctools_requirements">
<li>package require <b class="pkgname">doctools::toc::structure <span class="opt">?0.1?</span></b></li>
<li>package require <b class="pkgname">Tcl 8.4</b></li>
<li>package require <b class="pkgname">logger</b></li>
<li>package require <b class="pkgname">snit</b></li>
</ul>
<ul class="doctools_syntax">
<li><a href="#1"><b class="cmd">::doctools::toc::structure</b> <b class="method">verify</b> <i class="arg">serial</i> <span class="opt">?<i class="arg">canonvar</i>?</span></a></li>
<li><a href="#2"><b class="cmd">::doctools::toc::structure</b> <b class="method">verify-as-canonical</b> <i class="arg">serial</i></a></li>
<li><a href="#3"><b class="cmd">::doctools::toc::structure</b> <b class="method">canonicalize</b> <i class="arg">serial</i></a></li>
<li><a href="#4"><b class="cmd">::doctools::toc::structure</b> <b class="method">print</b> <i class="arg">serial</i></a></li>
<li><a href="#5"><b class="cmd">::doctools::toc::structure</b> <b class="method">merge</b> <i class="arg">seriala</i> <i class="arg">serialb</i></a></li>
</ul>
</div>
</div>
<div id="section1" class="doctools_section"><h2><a name="section1">Description</a></h2>
<p>This package provides commands to work with the serializations of
tables of contents as managed by the doctools system v2, and specified
in section <span class="sectref"><a href="#section3">ToC serialization format</a></span>.</p>
<p>This is an internal package of doctools, for use by the higher level
packages handling tables of contents and their conversion into and out
of various other formats, like documents written using <i class="term"><a href="../../../../index.html#doctoc">doctoc</a></i>
markup.</p>
</div>
<div id="section2" class="doctools_section"><h2><a name="section2">API</a></h2>
<dl class="doctools_definitions">
<dt><a name="1"><b class="cmd">::doctools::toc::structure</b> <b class="method">verify</b> <i class="arg">serial</i> <span class="opt">?<i class="arg">canonvar</i>?</span></a></dt>
<dd><p>This command verifies that the content of <i class="arg">serial</i> is a valid
<i class="term">regular</i> serialization of a table of contents and will throw an
error if that is not the case. The result of the command is the empty
string.</p>
<p>If the argument <i class="arg">canonvar</i> is specified it is interpreted as the
name of a variable in the calling context. This variable will be
written to if and only if <i class="arg">serial</i> is a valid regular
serialization. Its value will be a boolean, with <b class="const">True</b>
indicating that the serialization is not only valid, but also
<i class="term">canonical</i>. <b class="const">False</b> will be written for a valid, but
non-canonical serialization.</p>
<p>For the specification of regular and canonical serializations see the
section <span class="sectref"><a href="#section3">ToC serialization format</a></span>.</p></dd>
<dt><a name="2"><b class="cmd">::doctools::toc::structure</b> <b class="method">verify-as-canonical</b> <i class="arg">serial</i></a></dt>
<dd><p>This command verifies that the content of <i class="arg">serial</i> is a valid
<i class="term">canonical</i> serialization of a table of contents and will throw
an error if that is not the case. The result of the command is the
empty string.</p>
<p>For the specification of canonical serializations see the section
<span class="sectref"><a href="#section3">ToC serialization format</a></span>.</p></dd>
<dt><a name="3"><b class="cmd">::doctools::toc::structure</b> <b class="method">canonicalize</b> <i class="arg">serial</i></a></dt>
<dd><p>This command assumes that the content of <i class="arg">serial</i> is a valid
<i class="term">regular</i> serialization of a table of contents and will throw an
error if that is not the case.</p>
<p>It will then convert the input into the <i class="term">canonical</i> serialization
of the contained table of contents and return it as its result. If the
input is already canonical it will be returned unchanged.</p>
<p>For the specification of regular and canonical serializations see the
section <span class="sectref"><a href="#section3">ToC serialization format</a></span>.</p></dd>
<dt><a name="4"><b class="cmd">::doctools::toc::structure</b> <b class="method">print</b> <i class="arg">serial</i></a></dt>
<dd><p>This command assumes that the argument <i class="arg">serial</i> contains a valid
regular serialization of a table of contents and returns a string
containing that table in a human readable form.</p>
<p>The exact format of this form is not specified and cannot be relied on
for parsing or other machine-based activities.</p>
<p>For the specification of regular serializations see the section
<span class="sectref"><a href="#section3">ToC serialization format</a></span>.</p></dd>
<dt><a name="5"><b class="cmd">::doctools::toc::structure</b> <b class="method">merge</b> <i class="arg">seriala</i> <i class="arg">serialb</i></a></dt>
<dd><p>This command accepts the regular serializations of two tables of
contents and uses them to create their union.  The result of the
command is the canonical serialization of this unified table of
contents.</p>
<p>Title and label of the resulting table are taken from the table
contained in <i class="arg">serialb</i>.</p>
<p>The whole table and its divisions are merged recursively in the same
manner:</p>
<ol class="doctools_enumerated">
<li><p>All reference elements which occur in both divisions (identified by
their label) are unified with document id's and descriptions taken
from the second table.</p></li>
<li><p>All division elements which occur in both divisions (identified by
their label) are unified with the optional document id taken from the
second table, if any, or from the first if none is in the second. The
elements in the division are merged recursively using the same
algorithm as described in this list.</p></li>
<li><p>Type conflicts between elements, i.e. finding two elements with the
same label but different types result in a merge error.</p></li>
<li><p>All elements found in the second division but not in the first are
added to the end of the list of elements in the merge result.</p></li>
</ol>
<p>For the specification of regular and canonical serializations see the
section <span class="sectref"><a href="#section3">ToC serialization format</a></span>.</p></dd>
</dl>
</div>
<div id="section3" class="doctools_section"><h2><a name="section3">ToC serialization format</a></h2>
<p>Here we specify the format used by the doctools v2 packages to
serialize tables of contents as immutable values for transport,
comparison, etc.</p>
<p>We distinguish between <i class="term">regular</i> and <i class="term">canonical</i>
serializations.
While a table of contents may have more than one regular serialization
only exactly one of them will be <i class="term">canonical</i>.</p>
<dl class="doctools_definitions">
<dt>regular serialization</dt>
<dd><ol class="doctools_enumerated">
<li><p>The serialization of any table of contents is a nested Tcl dictionary.</p></li>
<li><p>This dictionary holds a single key, <b class="const">doctools::toc</b>, and its
value. This value holds the contents of the table of contents.</p></li>
<li><p>The contents of the table of contents are a Tcl dictionary holding the
title of the table of contents, a label, and its elements. The
relevant keys and their values are</p>
<dl class="doctools_definitions">
<dt><b class="const">title</b></dt>
<dd><p>The value is a string containing the title of the table of contents.</p></dd>
<dt><b class="const">label</b></dt>
<dd><p>The value is a string containing a label for the table of contents.</p></dd>
<dt><b class="const">items</b></dt>
<dd><p>The value is a Tcl list holding the elements of the table, in the
order they are to be shown.</p>
<p>Each element is a Tcl list holding the type of the item, and its
description, in this order. An alternative description would be that
it is a Tcl dictionary holding a single key, the item type, mapped to
the item description.</p>
<p>The two legal item types and their descriptions are</p>
<dl class="doctools_definitions">
<dt><b class="const">reference</b></dt>
<dd><p>This item describes a single entry in the table of contents,
referencing a single document.
To this end its value is a Tcl dictionary containing an id for the
referenced document, a label, and a longer textual description which
can be associated with the entry.
The relevant keys and their values are</p>
<dl class="doctools_definitions">
<dt><b class="const">id</b></dt>
<dd><p>The value is a string containing the id of the document associated
with the entry.</p></dd>
<dt><b class="const">label</b></dt>
<dd><p>The value is a string containing a label for this entry. This string
also identifies the entry, and no two entries (references and
divisions) in the containing list are allowed to have the same label.</p></dd>
<dt><b class="const">desc</b></dt>
<dd><p>The value is a string containing a longer description for this entry.</p></dd>
</dl></dd>
<dt><b class="const">division</b></dt>
<dd><p>This item describes a group of entries in the table of contents,
inducing a hierarchy of entries.
To this end its value is a Tcl dictionary containing a label for the
group, an optional id to a document for the whole group, and the list
of entries in the group.
The relevant keys and their values are</p>
<dl class="doctools_definitions">
<dt><b class="const">id</b></dt>
<dd><p>The value is a string containing the id of the document associated
with the whole group. This key is optional.</p></dd>
<dt><b class="const">label</b></dt>
<dd><p>The value is a string containing a label for the group. This string
also identifies the entry, and no two entries (references and
divisions) in the containing list are allowed to have the same label.</p></dd>
<dt><b class="const">items</b></dt>
<dd><p>The value is a Tcl list holding the elements of the group, in the
order they are to be shown.
This list has the same structure as the value for the keyword
<b class="const">items</b> used to describe the whole table of contents, see
above. This closes the recusrive definition of the structure, with
divisions holding the same type of elements as the whole table of
contents, including other divisions.</p></dd>
</dl></dd>
</dl></dd>
</dl>
</li>
</ol></dd>
<dt>canonical serialization</dt>
<dd><p>The canonical serialization of a table of contents has the format as
specified in the previous item, and then additionally satisfies the
constraints below, which make it unique among all the possible
serializations of this table of contents.</p>
<ol class="doctools_enumerated">
<li><p>The keys found in all the nested Tcl dictionaries are sorted in
ascending dictionary order, as generated by Tcl's builtin command
<b class="cmd">lsort -increasing -dict</b>.</p></li>
</ol></dd>
</dl>
</div>
<div id="section4" class="doctools_section"><h2><a name="section4">Bugs, Ideas, Feedback</a></h2>
<p>This document, and the package it describes, will undoubtedly contain
bugs and other problems.
Please report such in the category <em>doctools</em> of the
<a href="http://core.tcl.tk/tcllib/reportlist">Tcllib Trackers</a>.
Please also report any ideas for enhancements you may have for either
package and/or documentation.</p>
<p>When proposing code changes, please provide <em>unified diffs</em>,
i.e the output of <b class="const">diff -u</b>.</p>
<p>Note further that <em>attachments</em> are strongly preferred over
inlined patches. Attachments can be made by going to the <b class="const">Edit</b>
form of the ticket immediately after its creation, and then using the
left-most button in the secondary navigation bar.</p>
</div>
<div id="keywords" class="doctools_section"><h2><a name="keywords">Keywords</a></h2>
<p><a href="../../../../index.html#deserialization">deserialization</a>, <a href="../../../../index.html#doctoc">doctoc</a>, <a href="../../../../index.html#doctools">doctools</a>, <a href="../../../../index.html#serialization">serialization</a></p>
</div>
<div id="category" class="doctools_section"><h2><a name="category">Category</a></h2>
<p>Documentation tools</p>
</div>
<div id="copyright" class="doctools_section"><h2><a name="copyright">Copyright</a></h2>
<p>Copyright &copy; 2009 Andreas Kupries &lt;andreas_kupries@users.sourceforge.net&gt;</p>
</div>
</div></body></html>
